package net.itbaiyang.pattern.component.notification;

import jakarta.annotation.Resource;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SendMessageEventListener {

    @Resource
    private NotificationComponent notificationComponent;

    @EventListener
    public void handleSendMessageEvent(SendMessageEvent event) {
        String userId = event.getUserId();
        String message = event.getMessage();
        List<String> cIds = event.getCIds();
        // 调用个推API发送消息
        sendGeTuiMessage(userId, message,cIds);
    }

    private void sendGeTuiMessage(String userId, String message,List<String> cIds) {
        //
        Boolean b = notificationComponent.pushMessage(message,cIds);
        //对发送消息结果进行判断，存储发送状态
    }
}